import { FC, useState } from "react";
import Taro, { useShareAppMessage, useShareTimeline } from "@tarojs/taro";
import { View, Text, Radio, Button, Label } from "@tarojs/components";
import WechatLogin from "./components/wechat-login";
import PhoneLogin from "./components/phone-login";
import Register from "./components/register";
import styles from "./index.module.less";

const Login: FC = () => {
  const [isChecked, setIsChecked] = useState<boolean>(true);
  const [loginType, setLoginType] = useState<"wechat" | "phone" | "register">(
    "phone"
  );

  const onPay = () => {
    Taro.requestPayment({
      timeStamp: "",
      nonceStr: "",
      package: "",
      signType: "MD5",
      paySign: "",
      success: function (res) {},
      fail: function (res) {},
    });
  };

  useShareTimeline(() => {
    return {
      title: "全城丘比特",
    };
  });

  useShareAppMessage(() => {
    return {
      title: "全城丘比特",
    };
  });

  return (
    <View className={styles["login-wrapper"]}>
      {loginType === "wechat" && (
        <WechatLogin
          isChecked={isChecked}
          onSwitchPhone={() => setLoginType("phone")}
        />
      )}
      {loginType === "phone" && (
        <PhoneLogin
          isChecked={isChecked}
          onSwitchWechat={() => setLoginType("register")}
        ></PhoneLogin>
      )}

      {loginType === "register" && (
        <Register
          isChecked={isChecked}
          onSwitchWechat={() => setLoginType("phone")}
        />
      )}
      {/* <View className={styles["protocol-wrapper"]}>
        <Label
          className={styles["lb"]}
          onClick={() => setIsChecked(!isChecked)}
        >
          <Radio
            checked={isChecked}
            color="#FD486E"
            style={{ transform: "scale(0.6)" }}
          ></Radio>
          <Text>我已阅读并同意</Text>
        </Label>

        <Text
          className={styles["text"]}
          onClick={() =>
            Taro.navigateTo({
              url: "/package/member/protocol/index",
            })
          }
        >
          《用户协议》
        </Text>
        <Text
          className={styles["text"]}
          onClick={() =>
            Taro.navigateTo({
              url: "/package/member/protocol/index",
            })
          }
        >
          《隐私政策》
        </Text>
      </View> */}
    </View>
  );
};

export default Login;
